﻿using System.Web.Mvc;
using Castle.MicroKernel.Registration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OWE.Aspects;
using OWE.Core.Data;
using OWE.Data;
using OWE.Service.Accounting;
using OWE.Core.Domain;

namespace OWE.Web.Installation
{
    public class DependencyInstaller : IWindsorInstaller
    {
        public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
        {
            //Repositories
            container.Register(Component.For<IDbContext>().ImplementedBy<DapperContext>().LifeStyle.Transient);
            container.Register(Component.For<IRepository<AccountType>>().ImplementedBy<DapperRepository<AccountType>>().LifeStyle.Transient);
            container.Register(Component.For<IRepository<AccountMove>>().ImplementedBy<DapperRepository<AccountMove>>().LifeStyle.Transient);
            container.Register(Component.For<IRepository<Account>>().ImplementedBy<DapperRepository<Account>>().LifeStyle.Transient);

            //Service Registering
            container.Register(Component.For<IAccountService>().ImplementedBy<AccountService>().LifeStyle.Transient);

            //Controller registering
            container.Register(Classes.FromThisAssembly()
                           .BasedOn<IController>()
                           .LifestyleTransient());

            //Aspects
            container.Register(Component.For<ExceptionHandling>());
        }


    }
}